package beans;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import model.Citizen;
import dto.CitizenDTO;
import entitymanagers.CitizenManager;

@ManagedBean(name = "citizen")
@RequestScoped
public class CitizenBean {

	@EJB
	private CitizenManager citManager;
	
	private CitizenDTO citizen;
	
	public CitizenDTO getCitizen(){
		if (citizen == null){
			citizen = citManager.getPrincipal();
		}
		return citizen;
	}
	
	public String getPrincipalName(){
		return getCitizen().getName();
	}
}
